const TokenKey = 'Admin-Token'
const LegacyTokenKey = 'App-Token'

export function getToken() {
  const token = uni.getStorageSync(TokenKey)
  if (token) return token
  // 兼容旧键名
  return uni.getStorageSync(LegacyTokenKey)
}

export function setToken(token) {
  uni.setStorageSync(TokenKey, token)
  // 清理旧键，避免混乱
  try { uni.removeStorageSync(LegacyTokenKey) } catch (e) {}
  return
}

export function removeToken() {
  try { uni.removeStorageSync(TokenKey) } catch (e) {}
  try { uni.removeStorageSync(LegacyTokenKey) } catch (e) {}
  return
}
